* make dataset vertical with all single item w1 measures in col1, and w2 measures in col2. Individual revealed reliability is the correlation of the two vectors (columns), generated below. 


cd ""
clear 
set more off

use data_all_vars

*** all single items which can reasonably be expected to stay constant within the period between the two waves (excludes mood). 66 personality indicators, 21 other indicators for a total of 87 indicators.
local i=1
* all 87 indicators
foreach var of varlist  BFI2_1-SOEP_extra6   GPS_risk GPS_time  GPS_pres_bias GPS_alt GPS_trust GPS_pos_rec GPS_neg_rec_self GPS_neg_rec_self2 GPS_neg_rec_other      LS_gen section4* cog_*   {
	rename `var' wa1_`i' 
	rename w2_`var' wa2_`i'
	local++i
}


* standardizing for comparability 
foreach var of varlist wa1_* wa2_*  {
	sum `var' if `var'!=.
	replace `var'=(`var'-`r(mean)')/`r(sd)' if `var'!=.
	}

keep CID wa1_* wa2_*

*** only want individuals who participated in both survey waves
keep if wa2_1!=.


gen ind_id=_n

reshape long wa1_ wa2_, i(CID ind_id) j(item) 

sort CID item


* revealed individual reliability
gen tr_ind=.


gen long CID_corr=.
forvalues i=1(1)651 {
	capture corr  wa1_ wa2_ if ind_id==`i'
	replace tr_ind=`r(rho)' in `i'
	sum CID if ind_id==`i'
	replace CID_corr=`r(mean)' in `i'
}

keep tr_ind CID_corr
rename CID_corr CID

drop if CID==.

sort CID


save corrs_ind, replace





*** merge back individual measures for use in regression analysis
clear
use data_all_vars

sort CID
merge 1:1 CID using corrs_ind

keep if _merge==3
drop _merge


* puts BFI reliability on same scale as overall reliability	
foreach var in weight_w1w2_sure_pers {
    replace `var'=2*`var'
}
* continuous variable combining both self-reported reliability questions
gen w1w2_accuracy=w1w2_reliable+w1w2_sure_pers

*** normalize combined self-reported reliability 
foreach var of varlist  w1w2_accuracy {
	sum `var' if `var'!=.
	replace `var'=(`var'-`r(mean)')/`r(sd)' if `var'!=.
	
	}	

******************************* Exhibits Start ************************************************************************************

**************** Below Generates Table A.8

reg tr_ind t_recontact
outreg2 using reg_tr_ind_t_recontact.xls, replace dec(2) noomitted

reg tr_ind i.t_recontact_cat2
outreg2 using reg_tr_ind_t_recontact.xls, append dec(2) noomitted

reg tr_ind t_recontact if w1w2_sure_high==0
outreg2 using reg_tr_ind_t_recontact.xls, append dec(2) noomitted

reg tr_ind  i.t_recontact_cat2 if w1w2_sure_high==0
outreg2 using reg_tr_ind_t_recontact.xls, append dec(2) noomitted

reg tr_ind t_recontact if w1w2_sure_high==1
outreg2 using reg_tr_ind_t_recontact.xls, append dec(2) noomitted



reg tr_ind  i.t_recontact_cat2 if w1w2_sure_high==1
outreg2 using reg_tr_ind_t_recontact.xls, append dec(2) noomitted








**************** Below Generates Tables 4, A.13
foreach var of varlist tr_ind {
	foreach rel in sure_pers accuracy {

	reg `var' w1w2_`rel' 
	outreg2 using reg_`var'_controls_`rel'.xls, replace dec(2) noomitted

	reg `var'  w1w2_`rel' extra_inc  BFI_first GPA_first
	outreg2 using reg_`var'_controls_`rel'.xls, append dec(2) noomitted
	
	reg `var'  w1w2_`rel' av1_d_pct5_length_m
	outreg2 using reg_`var'_controls_`rel'.xls, append dec(2) noomitted
	


	 reg `var'   w1w2_`rel' male young pc i.country i.prof_relev i.edu_relev
	outreg2 using reg_`var'_controls_`rel'.xls, append dec(2) noomitted

	reg `var'  w1w2_`rel' w1w2_cognitive
	outreg2 using reg_`var'_controls_`rel'.xls, append dec(2) noomitted

	reg `var'   w1w2_`rel' w1w2_extrav w1w2_consci w1w2_neurot w1w2_agree w1w2_open  
	outreg2 using reg_`var'_controls_`rel'.xls, append dec(2) noomitted

	reg `var'    w1w2_`rel' w1w2_GPS_risk w1w2_GPS_time w1w2_GPS_pres_bias w1w2_GPS_neg_rec_self w1w2_GPS_neg_rec_self2 w1w2_GPS_neg_rec_other w1w2_GPS_alt w1w2_GPS_pos_rec  w1w2_GPS_trust
	outreg2 using reg_`var'_controls_`rel'.xls, append dec(2) noomitted


	 reg `var'   w1w2_`rel' extra_inc BFI_first GPA_first  av1_d_pct5_length_m  w1w2_extrav w1w2_consci w1w2_neurot w1w2_agree w1w2_open w1w2_cognitive w1w2_GPS_risk w1w2_GPS_time w1w2_GPS_pres_bias w1w2_GPS_neg_rec_self w1w2_GPS_neg_rec_self2 w1w2_GPS_neg_rec_other w1w2_GPS_alt w1w2_GPS_pos_rec  w1w2_GPS_trust male young pc i.country i.prof_relev i.edu_relev
	 outreg2 using reg_`var'_controls_`rel'.xls, append dec(2) noomitted
	}
}


**************** Below Generates Tables 4, A.14
reg  tr_ind extra_inc  BFI_first GPA_first
outreg2 using reg_tr_ind_controls.xls, replace dec(2) noomitted

reg  tr_ind av1_d_pct5_length_m
outreg2 using reg_tr_ind_controls.xls, append dec(2) noomitted


reg   tr_ind male young pc i.country i.prof_relev i.edu_relev
outreg2 using reg_tr_ind_controls.xls, append dec(2) noomitted


reg  tr_ind w1w2_cognitive
outreg2 using reg_tr_ind_controls.xls, append dec(2) noomitted

reg   tr_ind w1w2_extrav w1w2_consci w1w2_neurot w1w2_agree w1w2_open  
outreg2 using reg_tr_ind_controls.xls, append dec(2) noomitted

reg    tr_ind w1w2_GPS_risk w1w2_GPS_time w1w2_GPS_pres_bias w1w2_GPS_neg_rec_self w1w2_GPS_neg_rec_self2 w1w2_GPS_neg_rec_other w1w2_GPS_alt w1w2_GPS_pos_rec  w1w2_GPS_trust
outreg2 using reg_tr_ind_controls.xls, append dec(2) noomitted


reg tr_ind  extra_inc BFI_first GPA_first av1_d_pct5_length_m  w1w2_extrav w1w2_consci w1w2_neurot w1w2_agree w1w2_open w1w2_cognitive  w1w2_GPS_risk w1w2_GPS_time w1w2_GPS_pres_bias w1w2_GPS_neg_rec_self w1w2_GPS_neg_rec_self2 w1w2_GPS_neg_rec_other w1w2_GPS_alt w1w2_GPS_pos_rec  w1w2_GPS_trust male young pc i.country i.prof_relev i.edu_relev
outreg2 using reg_tr_ind_controls.xls, append dec(2) noomitted sortvar(extra_inc BFI_first GPA_first av1_d_pct5_length_m  w1w2_extrav w1w2_consci w1w2_neurot w1w2_agree w1w2_open w1w2_cognitive  w1w2_GPS_risk w1w2_GPS_time w1w2_GPS_pres_bias w1w2_GPS_neg_rec_self w1w2_GPS_neg_rec_self2 w1w2_GPS_neg_rec_other w1w2_GPS_alt w1w2_GPS_pos_rec  w1w2_GPS_trust male young pc)
 
 
 
 
**************** Below Generates Tables A.10
reg tr_ind av1_d_pct5_length_m length_m w2_length_m 
outreg2 using reg_tr_ind_E.xls, replace dec(2) noomitted
reg tr_ind av1_d_pct5_length_m w1w2_length_m
outreg2 using reg_tr_ind_E.xls, append dec(2) noomitted
reg tr_ind av1_d_pct10_length_m w1w2_length_m
outreg2 using reg_tr_ind_E.xls, append dec(2) noomitted
reg tr_ind av1_d_pct15_length_m w1w2_length_m
outreg2 using reg_tr_ind_E.xls, append dec(2) noomitted
reg tr_ind av1_d_pct20_length_m w1w2_length_m
outreg2 using reg_tr_ind_E.xls, append dec(2) noomitted sortvar( length_m w2_length_m  w1w2_length_m av1_d_pct5_length_m av1_d_pct10_length_m av1_d_pct15_length_m av1_d_pct20_length_m) 

 


**************** Below Generates Table 3
foreach var of varlist tr_ind  {
	reg `var' w1w2_sure_pers
	outreg2 using reg_`var'_holdout.xls, replace dec(2) noomitted

	reg `var' w1w2_reliable
	outreg2 using reg_`var'_holdout.xls, append dec(2) noomitted

	reg `var'  c.w1w2_reliable##c.w1w2_sure_pers
	outreg2 using reg_`var'_holdout.xls, append dec(2) noomitted sortvar( w1w2_sure_pers w1w2_reliable)


}

	
